#!/bin/sh

#this script compile and run the program.

compilationCommand="mpicc *.c -fopenmp"

x=a
i=0

echo "q: quit"
echo "anything else: compile and run again"
echo

$compilationCommand && echo "compilation ok"

while expr ${x}q != qq >/dev/null
do
	i=`expr $i + 1`

	echo "running program with $i process"

	if ( /usr/bin/time --verbose -o time.txt -a mpirun -np $i a.out -pp shakespe.txt )
	then
		echo "program ok"
		echo >> time.txt
		echo >> time.txt
	fi

	read x
done
